<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var arr = [1, 2, 3, 4]
    // 代码不简洁
    for (var i = 0; i < arr.length; i++) {
        if (i == 2) {
            continue
        }
        console.log(arr[i]);
    }
    // 不能结束循环
    arr.forEach(item => {
        // if (item = 2) {
        //     continue
        // }
        console.log(item);
    })
    // 字符串类型
    for (let key in arr) {
        console.log(key);
    }
    // 不能获取索引
    console.log(...arr);

    console.log(111111111);
    for (let key of arr) {
        if (key == 2) {
            continue
        }
        console.log(key);
    }
    for (let key of arr.keys()) {
        console.log(key);
    }
    console.log(2222222222);

    for (let [key, value] of arr.entries()) {
        console.log(key, value);
    }

    var str = '我们都是好孩子'
    for (let key of str) {
        console.log(key);
    }

    var obj = {
        name: 'zs',
        age: 18
    }
    // obj is not iterable
    for (let key of obj) {
        console.log(key);
    }
    // 可遍历对象：可以被for..of遍历的对象叫做可遍历对象，数组，字符串，伪数组，Set, Map
</script>

</html>